package de.slothsoft.wasbinich.swingclient.control;

import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.GridBagLayout;

import javax.swing.JLabel;
import javax.swing.JPanel;

import de.slothsoft.commons.swing.GridBagUtil;
import de.slothsoft.wasbinich.core.ApplicationInfo;
import de.slothsoft.wasbinich.core.util.CommonUtil;
import de.slothsoft.wasbinich.swingclient.res.AndroidMessages;

public class ApplicationInfoPanel extends JPanel {

    private static final long serialVersionUID = 3288426773224838459L;

    public ApplicationInfoPanel(ApplicationInfo info) {
	setLayout(new GridBagLayout());
	setBackground(new Color(255, 255, 255, 127));
	createControls(info);
    }

    private void createControls(ApplicationInfo info) {
	int x = 0, y = 0;
	add(createLabel(AndroidMessages.getDefault("info_label_version")), GridBagUtil.labelDefaults(x, y++));
	add(createText(info.version), GridBagUtil.labelDefaults(x, y++));
	add(createLabel(AndroidMessages.getDefault("info_label_pictures")), GridBagUtil.labelDefaults(x, y++));
	add(createText(info.pictureCount + ""), GridBagUtil.labelDefaults(x, y++));
	add(createLabel(AndroidMessages.getDefault("info_label_languages")), GridBagUtil.labelDefaults(x, y++));
	add(createText(CommonUtil.createLanguagesString(info.supportedLanguages) + ""),
		GridBagUtil.labelDefaults(x, y++));

	add(new JLabel(), GridBagUtil.componentDefaults(x, 10));
    }

    protected Component createText(String text) {
	JLabel result = new JLabel(text);
	result.setFont(result.getFont().deriveFont(Font.PLAIN));
	return result;
    }

    protected Component createLabel(String text) {
	JLabel result = new JLabel(text + ":");
	result.setFont(result.getFont().deriveFont(Font.BOLD, getFont().getSize() + 1));
	return result;
    }

}
